#ifndef ENTITY_H
#define ENTITY_H

#include <stdio.h>
#include "battle.h"
#include "engine.h"
#include "main.h"

struct chrrec {
    char fname[13] __attribute__ ((packed));
};

struct entitydata {
    // starting/current location
    int x;
    int y;
    // CHR index
    unsigned char chrindex;
    // movement pattern code
    unsigned char movecode;
    // activation mode
    unsigned char activmode;
    // obstruction mode
    unsigned char obsmode;
    // script references
    unsigned int actscript;
    unsigned int movescript;
    // entity speed multiplier
    unsigned char spedm;
    // entity speed divisor
    unsigned char spedd;
    // Misc data entries
    unsigned short data1;
    unsigned short data2;
    unsigned short data3;
    // More misc data
    unsigned short data4;
    // Editing description
    char entitydesc[20];
};

// CHR list
extern struct chrrec chrlist[100];
// number of active entities
extern int entities;
// number of movement scripts
extern unsigned char nummovescripts;
// movement script offset table
extern int msofstbl[100];
// movement script data buffer
extern char* msbuf;
// if call to MoveXX() was successful
extern char movesuccess;

extern int EntityAt(int ex,int ey);
extern int AnyEntityAt(int ex,int ey);
extern void MoveRight(int i);
extern void MoveLeft(int i);
extern void MoveUp(int i);
extern void MoveDown(int i);
extern int Zone(int cx, int cy);
extern void ProcessSpeedAdjEntity(int i);
extern void Wander1(int i);
extern void Wander2(int i);
extern void Wander3(int i);
extern void Whitespace(int i);
extern void GetArg(int i);
extern void GetNextCommand(int i);
extern void MoveScript(int i);
extern void TestActive(int i);
extern void Chase(int i);
extern void CheckChasing(int i);
extern void ProcessEntity(int i);

#endif
